// Copyright 2010 - eggsy _at_ eggsylife.co.uk
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package uk.co.eggsylife;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import uk.co.eggsylife.async.command.ServerCommandImpl;

import com.google.gson.Gson;

public class TwitterUserInfoCommand extends ServerCommandImpl{

	public TwitterUserInfoCommand(String serverUrl) {
		super(serverUrl);
	}


	public TwitterUserModeltem performCommand(String username) {
		
		// Twitter Username request needs a screen_name parameter
		// For more specific implementation on the Twitter API for this request
		// See: http://dev.twitter.com/doc/get/users/show 
		HashMap<String, List<String>> requestParams = new HashMap<String, List<String>>();
		ArrayList<String> values = new ArrayList<String>();
		values.add(username);
		requestParams.put("screen_name", values);
		
		// Make the server request which results in JSON as a String
		String requestResult = executeGetRequest(requestParams);
		
		// In this example I use Gson to convert my response into
		// a POJO - You can of course use any library you like
		// to convert you String of JSON 
		Gson gson = new Gson();
		TwitterUserModeltem response = gson.fromJson(requestResult, TwitterUserModeltem.class);
		return response;
	}
}
